<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2009 Thomas Breuss <thomas.breuss@zephir.ch>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 * Hint: use extdeveval to insert/update function index above.
 */

require_once(PATH_tslib.'class.tslib_pibase.php');
require_once(t3lib_extMgm::extPath('zlib') . 'class.tx_zlib_controller.php');

/**
 * Plugin 'ZLIB Test' for the 'zlibtest' extension.
 *
 * @author	Thomas Breuss <thomas.breuss@zephir.ch>
 * @package	TYPO3
 * @subpackage	tx_zlibtest
 */
class tx_zlibtest_pi1 extends tx_zlib_controller
{
	var $prefixId      = 'tx_zlibtest_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_zlibtest_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'zlibtest';	// The extension key.
	var $pi_checkCHash = true;
	var $view;


	function defaultAction()
	{

    	$this->render('test');

        foreach(get_class_methods($this) AS $method) {
            if(substr($method, 0, 4) == 'test') {
            	$this->view->clearVars();
                $this->$method();
            }
        }

	}

	public function testForeach()
	{
		$books = array(
		    array(
		        'author' => 'J. K. Rowling',
		        'title' => 'Harry Potter and the Deathly Hallows'
		    ),
		    array(
		        'author' => 'Khaled Hosseini',
		        'title' => 'A Thousand Splendid Suns'
		    ),
		    array(
		        'author' => 'Milton Friedman',
		        'title' => 'Free to Choose'
		    ),
		    array(
		    	'author' => 'Jeffrey Toobin',
		    	'title' => 'The Nine: Inside the Secret World of the Supreme Court'
		    ),
		    array(
		    	'author' => 'J. R. R. Tolkien',
		    	'title' => 'The Children of Hurin'
		    )
		);
		$this->view->books = $books;
		$this->render('foreach');
	}

	public function testTranslate()
	{
		$this->render('translate');
	}

	public function testLink()
	{
		$this->view->id = $GLOBALS['TSFE']->page['uid'];
		$this->render('link');
	}

	public function testTable()
	{
        $this->view->data = array(
        	array('id' => 43, 'name' => 'Peter', 'birthday' => '1991/8/12'),
        	array('id' => 67, 'name' => 'Paul', 'birthday' => '1990/11/17'),
        	array('id' => 89, 'name' => 'Mary', 'birthday' => '1999/7/22'),
        	array('id' => 23, 'name' => 'Tom', 'birthday' => '1995/5/12'),
        	array('id' => 25, 'name' => 'Sue', 'birthday' => '1992/6/21')
        );
		$this->view->columns = array(
			array('key' => 'id', 'label' => 'ID'),
			array('key' => 'name', 'label' => 'Name'),
			array('key' => 'birthday', 'label' => 'Birthday')
		);
		$this->view->fields = array(
			array('key' => 'id'),
			array('key' => 'name'),
			array('key' => 'birthday')
		);
		$this->render('table');
	}

	public function testImage()
	{
		$this->render('image');
	}

	public function testMailto()
	{
		$this->render('mailto');
	}

	public function testEnv()
	{
		$this->render('env');
	}

	public function testPage()
	{
		$this->render('page');
	}

	public function testRte()
	{
		$this->view->prefixId = $this->prefixId;
		$this->view->rteTest1 = isset($this->piVars['rteTest1']) ? $this->piVars['rteTest1'] : 'That is a sample text 1';
		$this->view->rteTest2 = isset($this->piVars['rteTest2']) ? $this->piVars['rteTest2'] : 'That is a sample text 2';
		$this->render('rte');
	}

	public function testFileinfo()
	{
		$this->render('fileinfo');
	}

	public function testFeuser()
	{
		$this->render('feuser');
	}

	public function testExtConf()
	{
		$this->render('extconf');
	}

}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zlibtest/pi1/class.tx_zlibtest_pi1.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zlibtest/pi1/class.tx_zlibtest_pi1.php']);
}

?>